package actions.manager;

import java.util.ArrayList;

import veilingDomein.User;
import veilingService.ServiceProvider;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class BlokkeerUser extends ActionSupport {
	public ArrayList<User>users = ServiceProvider.getUserService().getUsers();
	
	private String reden;
	private String totDatum;
	private String username;

	User user;
	
	public String execute() {
		user = ServiceProvider.getUserService().getUser(username);
		System.out.println(user);
		ServiceProvider.getUserService().BlokkeerUser(user, totDatum, reden);
		addActionMessage("Gebruiker Succesvol geblokkeerd!");
		return SUCCESS;
	}
	public void validate() {
		if ( reden.length() == 0 ){			
			addFieldError( "reden", "Geef a.u.b een reden");
		}
		if ( totDatum.length() == 0 ){			
			addFieldError( "totDatum", "Geef a.u.b een eind datum");
		}
	}	
	
	public ArrayList<User> getUsers() {
		return users;
	}
	public void setUsers(ArrayList<User> users) {
		this.users = users;
	}
	public String getReden() {
		return reden;
	}
	public void setReden(String reden) {
		this.reden = reden;
	}
	public String getTotDatum() {
		return totDatum;
	}
	public void setTotDatum(String totDatum) {
		this.totDatum = totDatum;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}

}
